import {commomParams,options} from "./config.js";
import jsonp from "commom/js/jsonp"
import axios from 'axios'

export function gethHotKeys(){
  const url = "https://c.y.qq.com/splcloud/fcgi-bin/gethotkey.fcg"
  const data = {
    g_tk: 1928093487,
    inCharset: 'utf-8',
    format: 'jsonp',
    uin: 0,
    needNewCode: 1,
    platform: 'h5'
  }
  let urldata = Object.assign({},commomParams,data);
  return jsonp(url,urldata,options)
}

export function search(querry,page,zhida,perpage,){
  const url = "/api/search";
  let data = {
    uin: 240046220,
    inCharset: 'utf-8',
    needNewCode: 1,
    w: querry,
    zhidaqu: 1,
    catZhida: zhida ? 1 : 0,
    t: 0,
    flag: 1,
    ie: 'utf-8',
    sem: 1,
    aggr: 0,
    perpage: perpage,
    n: perpage,
    p: page,
    remoteplace: 'txt.mqq.all'
  }
  let urldata = Object.assign({},commomParams,data);
  return axios.get(url,{
    params:urldata
  }).then((res)=>{
    return Promise.resolve(res.data)
  })
}
